exports.imgUpload = function(req,res){

	if (Object.keys(req.files).length != 0){
		console.log("文件来了!!");
	  console.log(req.files);
		return res.status(200).send('Files were uploaded.');
	}else{
		return res.status(500).send(err);
	}



};

exports.saveShopdata = function(req,res){
	if(!req.files){
		return res.status(400).send('No files were uploaded');
	}
	//获取上传图片
	let shopImage = req.files.shopImage;
	console.log(shopImage);
	// var logoPath = "E:\\LL-project\\ordersystem\\upload\\"+shopImage.name;
	// shopImage.mv("E:\\LL-project\\ordersystem\\upload\\"+shopImage.name,function(err){
	var logoPath = "/home/ordersystem/Image/logo"+shopImage.name;
	shopImage.mv(logoPath,function(err){
		if(err){
			return res.status(500).send(err);
		}
		console.log("File uploaded!")
	});
	req.getConnection(function(err,conn){
		if(err){
			res.status(500).send(err);
		}
		console.log(req.body);
		var post = {
			name:req.body.shop_name,
			table_num : req.body.table_num,
			telephone : req.body.telephone,
			img : logoPath,
			address : req.body.address

		};
	    var sql = 'INSERT INTO shop_list SET ?' ;
		var query = conn.query(sql,post,function(err,res){
			if(err){
				console.log(err);
			}else{
			  console.log("1 record inserted");
			}
		})
	});
	res.redirect('/#/app/shopSet');
}







